package study.cdc.debezium.support.debezium;

import cn.hutool.json.JSONUtil;
import io.debezium.engine.ChangeEvent;
import lombok.extern.slf4j.Slf4j;
import study.cdc.debezium.support.utils.Payload;

@Slf4j
public class ChangeEventConsumer {

    public void handle(ChangeEvent<String, String> event) {
        //log.info(">>>>>>> {}", event.destination());
        //log.info(">>>>>>> {}", event.key());
        //log.info(">>>>>>> {}", event.value());
        Payload payload = JSONUtil.toBean(event.value(), Payload.class);
        log.info(">>>>>> pos= {}", payload.getSource().getPos());
        if (payload != null) {
            //log.info(">>>>>> {}, {}", payload.operation(), payload.getSource().getPos());
        }
    }
}
